import { useEffect, useState } from 'react'
import {getChannelsAPI} from '@/apis/active'

const useChannel  =()=>{

  //评到列表
  const [channelList,setChannelList ] = useState ([])
  useEffect( ()=>{
   const getChannelList =async()=>{
      //封装调用后台函数
      const res  =  await getChannelsAPI()
 
      setChannelList(res.data.data.channels)
   }
   //调用后台函数
   getChannelList()
  },[])

  return {
    channelList   //将相应的数据导出
  }
}

export {useChannel}